import 'package:flutter/material.dart';

import './tabs/Tab.dart';
import './pages/Category.dart';
import './pages/home.dart';
import './pages/person.dart';
import './pages/shop_car.dart';
import 'package:fluro/fluro.dart';
import './pages/detail_pages.dart';

Handler detailsHandler = Handler(
  handlerFunc: (BuildContext context,Map<String,List<String>> params){
    String goodsId = params['id'].first;
    print('index.details goodsId is ${goodsId}');
    return DetailPage(goodsId);
  }
);

final routes={
  '/':(context)=>Tabs(),
  '/category':(context)=>CategoryPage(),
  '/home':(context)=>HomePage(),
  '/shopcar':(context)=>ShopCarPage(),
  '/person':(context)=>PersonPage(),
  '/detail':(context)=>DetailPage("000"),
};

//固定写法
var onGenerateRoute=(RouteSettings settings) {
  // 统一处理
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    }else{
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context));
      return route;
    }
  }
};